<?php

class ControllerXuesheng extends GetLoad
{

	

	public function index(){

		$this->load("Model/xuesheng");
		$xuesheng=new ModelXuesheng();
		$this->load("Model/name");
		
		$namezhuan=new Modelnamezhuanhua();
		$class=$namezhuan->getname($_COOKIE['name'])['class'];
		$tongxue=$xuesheng->Gettongxue($class);
		$data['class']=$xuesheng->Getclass($class)['name'];

		foreach ($tongxue as $value) {
			$data['tongxue'][] = array(
				'xuhao' => $value['name_id'], 
				'name'  => $value['name'], 
				'zhiwu' => "学生"

			);
		}


		$this->view("view/xuesheng",$data);
		//var_dump($data);
	//	echo "string*************************************************************";
		//$this->xiaozu();
		//echo "string*************************************************************";
		//$this->wodexiaozu();
		//echo "string*************************************************************";
		//$this->xiaozuchengyuan(1);



	}

	public function xiaozu(){

		$this->load("Model/xuesheng");
		$xuesheng=new ModelXuesheng();
		$this->load("Model/name");
	
		$namezhuan=new Modelnamezhuanhua();
		$class=$namezhuan->getname($_COOKIE['name'])['class'];
		echo $class;
		$xiaozu=$xuesheng->Getxiaozu($class);
		foreach ($xiaozu as $key => $one) {

			$chengyuan=$xuesheng->Getxiaozuchengyuan($one['xiaozu_id']);
			foreach ($chengyuan as $value) {
				$data[$key][] = array(
					'name'   => $namezhuan->getname_id($value['chengyuan_id'])['name'], 
					'zuhao'  => $value['zuhao'], 
					'laoshi' => $namezhuan->getname_id($one['laoshi'])['name']
				);
			}
			
		}
			$this->view("view/xiaozu",$data);

		//var_dump($data);
	}

	public function wodexiaozu(){



		$this->load("Model/xuesheng");
		$xuesheng=new ModelXuesheng();
		$this->load("Model/name");

		$namezhuan=new Modelnamezhuanhua();
		$class=$namezhuan->getname($_COOKIE['name'])['class'];
		$name_id=$namezhuan->getname($_COOKIE['name'])['name_id'];
		$xiaozu=$xuesheng->Getxiaozume($name_id);
		foreach ($xiaozu as $value) {
			$data[] = array(
				'zuhao' => $value['zuhao'], 
				'kemu'  => $xuesheng->Getlaoshi($value['xiaozu_id']), 
			);
		}


		$this->view("view/wodexiaozu",$data);

	}


	public function xiaozuchengyuan($jieshou){
		$xiaozu_id=$jieshou[0];
		$this->load("Model/xuesheng");
		$this->load("Model/name");
		$namezhuan=new Modelnamezhuanhua();
		$xuesheng=new ModelXuesheng();
		$chengyuan=$xuesheng->Getxiaozuone($xiaozu_id);
		foreach ($chengyuan as  $value) {
			$data[] = array(
				'name' => $namezhuan->getname_id($value['chengyuan_id'])['name'],
				'kemu'  => $xuesheng->Getlaoshi($value['xiaozu_id'])
				 );
		}



		$this->view("view/xiaozuchengyuan",$data);
	}

	public function shiyanbaogao($jieshou){
		$data['guanlizhe_id']=$jieshou[0];
		$data['shiyanshi_id']=$jieshou[1];

		$this->load("Model/shiyanshi");
		$this->load("Model/name");
		$this->load("Model/xuesheng");
		$shiyanshi=new Modelshiyanshi();
		$yanzheng=new Modelnamezhuanhua();
		$xuesheng=new ModelXuesheng();
		$class=$yanzheng->getname($_COOKIE['name'])['class'];
		$data['shiyanshi1']=$shiyanshi->Getshiyanshione($data['shiyanshi_id'])['haoma'];
		if($yanzheng->yanzheng1()){



				$reluse=$xuesheng->Getlaoshime($class);
				foreach ($reluse as  $value) {
					$data['laoshi'][] = array(
						'id' =>$value['laoshi_id'] ,
						'name'=>$yanzheng->getname_id($value['laoshi_id'])['name']
						 );
					
				}

					$data['shiyanshi']=$shiyanshi->Getshiyanshi1();
				
				if($data['shiyanshi_id']!=0){
					$data['yiqi']=$shiyanshi->Getyiqi($data['shiyanshi_id']);
				}


				$this->view("view/jianlishiyanbaogao",$data);




		}
	}

	public function shiyanbaogaov($jieshou){
		$key=$jieshou[0];
		$data['laoshi']=$jieshou[1];
		$data['shiyanshi']=$jieshou[2];
		$this->load("Model/shiyanshi");
		$this->load("Model/xuesheng");
		$this->load("Model/name");
		$xuesheng=new ModelXuesheng();
		$shiyanshi=new Modelshiyanshi();
		$yanzheng=new Modelnamezhuanhua();
		$name_id=$yanzheng->getname($_COOKIE['name'])['name_id'];

		if($_POST['title']){
			$data['xiaozu']=$_COOKIE['name'];
			$shiyanshi->xieshiyanbaogao($data,$name_id);


		}else{

			$this->view("view/shiyanbaogaov",$data);
		}




	}



















}
